using System;
using DirkRettschlag.Utils;
using System.Drawing;


namespace Departure
{
    public class SkinSettings
    {
        #region Variables

        string skinFile;

        Settings settings;
        Color fontColor;
        Color laterColor;
        bool boldTime;
        bool boldTrain;

        string backGroundItemPath;
        Bitmap backGroundItem;
        string backGroundItemSelectedPath;
        Bitmap backGroundItemSelected;
        string backGroundPath;
        Bitmap backGround;
        string fastAccessPath;
        Bitmap fastAccess;

        #endregion Variables
                     
        #region Properties

        public string SkinFile
        {
            get { return this.skinFile; }
            set { this.skinFile = value; }
        }

        public bool BoldTrain
        {
            get { return this.boldTrain; }
            set { this.boldTrain = value; }
        }

        public bool BoldTime
        {
            get { return this.boldTime; }
            set { this.boldTime = value; }
        }

        public System.Drawing.Color LaterColor
        {
            get { return this.laterColor; }
            set { this.laterColor = value; }
        }

        public System.Drawing.Color FontColor
        {
            get { return this.fontColor; }
            set { this.fontColor = value; }
        }

        public System.Drawing.Bitmap BackGroundItem
        {
            get { return this.backGroundItem; }
            set { this.backGroundItem = value; }
        }

        public System.Drawing.Bitmap BackGroundItemSelected
        {
            get { return this.backGroundItemSelected; }
            set { this.backGroundItemSelected = value; }
        }

        public System.Drawing.Bitmap BackGround
        {
            get { return this.backGround; }
            set { this.backGround = value; }
        }

        public System.Drawing.Bitmap FastAccess
        {
            get { return this.fastAccess; }
            set { this.fastAccess = value; }
        }

        #endregion Properties

        #region Constructor

        public SkinSettings()
        {
            backGround = new Bitmap(240, 320);
            backGroundItem = new Bitmap(240, 46);
            backGroundItemSelected = new Bitmap(240, 46);
            fastAccess = new Bitmap(80, 40);
        }

        public SkinSettings(string SkinFile): this()
        {
            this.skinFile = SkinFile;
        }

        #endregion Constructor

        #region Public Methods

        public void saveSettings()
        {
            settings = new Settings(Utilities.AppPath() + "\\skins\\" + skinFile);
            settings.WriteColor("Main", "FontColor", fontColor);
            settings.WriteColor("Main", "LaterColor", laterColor);
            settings.WriteBool("Main", "BoldTime", boldTime);
            settings.WriteBool("Main", "BoldTrain", boldTrain);
            settings.WriteString("Main", "BackGround", backGroundPath);
            settings.WriteString("Main", "BackGroundItem", backGroundItemPath);
            settings.WriteString("Main", "BackGroundItemSelected", backGroundItemSelectedPath);
            settings.WriteString("Main", "FastAccess", fastAccessPath);

            settings.Save();

        }

        public void getSettings()
        {

            settings = new Settings(Utilities.AppPath() + "\\skins\\" + skinFile);
            fontColor = settings.ReadColor("Main", "FontColor", Color.Black);
            laterColor = settings.ReadColor("Main", "LaterColor", Color.Red);
            boldTime = settings.ReadBool("Main", "BoldTime", false);
            boldTrain = settings.ReadBool("Main", "BoldTrain", false);
            backGroundPath = settings.ReadString("Main", "BackGround", "");
            backGroundItemPath = settings.ReadString("Main", "BackGroundItem", "");
            backGroundItemSelectedPath = settings.ReadString("Main", "BackGroundItemSelected", "");
            fastAccessPath = settings.ReadString("Main", "FastAccess", "");

            try
            {
                backGround = new Bitmap(Utilities.AppPath() + "\\skins\\" + skinFile.Replace(".skin", "\\") + backGroundPath);
                backGroundItem = new Bitmap(Utilities.AppPath() + "\\skins\\" + skinFile.Replace(".skin", "\\") + backGroundItemPath);
                backGroundItemSelected = new Bitmap(Utilities.AppPath() + "\\skins\\" + skinFile.Replace(".skin", "\\") + backGroundItemSelectedPath);
                fastAccess = new Bitmap(Utilities.AppPath() + "\\skins\\" + skinFile.Replace(".skin", "\\") + fastAccessPath);
            }
            catch
            {
            }

        }

        #endregion Public Methods

    }
}
